//
//  script.m
//  wiSync
//
//  Created by Javier Segura Perez on 12/9/07.
//  Copyright 2007 iFrancis Development Team. All rights reserved.
//

#import "Script.h"


@implementation Script
- (NSString *) runCommand:(NSString *)cmd
{

	FILE			*ptr;
	char			buf[BUFSIZ];
	NSMutableString	*result = [NSMutableString stringWithString:@"Script Executed. Nothing to show."];
	
	ptr = popen([cmd UTF8String], "r");
	if (ptr != NULL)
	{
		while ((fgets(buf, BUFSIZ, ptr)) != NULL)
			[result setString:[NSMutableString stringWithUTF8String:buf]];
		pclose(ptr);		
	}
	return [result stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
}

@end
